﻿//===============================================================================
// Apolineo Patterns & Practices LeanEngine Framework
//===============================================================================
// Copyright © Apolineo Desenvolvimento de Sistemas Ltda.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LeanEngine.SalesConcept.Windows
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }

        //Método genérico para exibição de um formulario
        private void ShowForm<T>()
            where T : Form, new()
        {
            var form = new T();
            form.FormClosed += new FormClosedEventHandler(form_FormClosed);
            form.MdiParent = this;

            form.Show();
        }

        void form_FormClosed(object sender, FormClosedEventArgs e)
        {
            (sender as Form).Dispose();
            sender = null;
        }

        private void sairToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void novoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShowForm<FormMaintenanceProduct>();
        }

        private void pesquisarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShowForm<FormSearchProduct>();
        }

        private void novoToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            ShowForm<FormMaintenanceCustomer>();
        }

        private void pesquisarToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            ShowForm<FormSearchCustomer>();
        }

        private void novoToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            ShowForm<FormMaintenanceSalesman>();
        }

        private void pesquisarToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            ShowForm<FormSearchSalesman>();
        }

        private void incluirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShowForm<FormMaintenanceSale>();
        }

        private void pesquisarToolStripMenuItem3_Click(object sender, EventArgs e)
        {
            ShowForm<FormSearchSale>();
        }
    }
}
